home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 45
/
Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso
/
Aminet
/
comm
/
amiex
/
news2ae.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1995-09-17
|
18KB
|
540 lines
/*****************************************************************************/
/* */
/* news 2 AmiExpress v0.9 */
/* */
/* Convert news messages into AmiExpress messages */
/* I use this tool because I get the the news using AMiTCP and plink and just*/
/* wanted to somehow convert them into my AmiExpress message base. Well it */
/* works just fine. REMEMBER make sure you backup your message base when you */
/* test this. Sometime ago AE had a different messsage base structure and it */
/* might not work for you if you have older ver of AE. But anyway it works */
/* just fine. If you have problems of any type please email me at: */
/* falco@falco.escape.com, ftp to falco.escape.com or telnet to it. */
/* Also you can call my bbs at 718-318-8315, have fun and l8r. If you have */
/* any comments or problems or whatever feel free to email me. This tool was */
/* done in 30 mins so it might be not perfect but for me it does what it had */
/* to do and I am happy. I might add some more stuff to it but who knows. l8r*/
/* */
/*****************************************************************************/
CALL TIME('R')
addlib('rexxsupport.library',0,-30)
dir = "Confs:Conf019/"
UUNewsFalco = "uunews:comp/sys/amiga/marketplace/"
MessyType = "P"
ToWhom = "All"
/*****************************************************************************/
/*****************************************************************************/
/* Known bugs: */
/* */
/* - None */
/* */
/*****************************************************************************/
/*****************************************************************************/
say ""
say CENTER("News2AmiExpress v1.0",70)
say ""
say CENTER("Copyright © 1995 by Kool Falco",70)
say CENTER("All rights reserved",70)
say ""
/*say dir*/
/*say UUNewsFalco*/
if EXISTS(UUNewsFalco||".next") then do
call open MyFile,(UUNewsFalco||".next"),'R'
NumberOfMessages = readln(MyFile)
NumberOfMessages = NumberOfMessages - 1
say NumberOfMessages||" new messages found..."
CLOSE(MyFile)
end
else do
say ""
say "ERROR: Cannot find "||UUNewsFalco||".next file."
say ""
SAY 'Elapsed time='TIME('E')' seconds.'
Exit
end
i = 1 /*************** USE THIS ONE *****************/
/*i = 13*/ /**** TEMPORARY ****/
/*do while (i <= 2)*/ /**** TEMPORARY ****/
do while (i <= NumberOfMessages) /**********USE THIS LINE************/
if EXISTS(UUNewsFalco||i) then do
say "######## N E W Message ########"
call open MyTmpMsg,("ram:tmp.msg"),'W'
say "working on message # ==> "||i
/* Reset those stats b4 each message. Then */
/* if those values are not = to "" then */
/* the value is already read and dont have */
/* to read it again. */
MessageFrom = ""
MessageSubject = ""
MessageDate = ""
MessageToEmail = "" /* Put this to comment of a message and then use to reply to it. */
FirstEmptyLine = "NO"
MessageFromEmail = ""
call open MyFile,(UUNewsFalco||i),'R'
do while ~EOF(MyFile)
WholeLine = readln(MyFile)
/*Subject: WTB: ZIP 256k RAM (PM) a3000*/
if (POS("Subject: ",WholeLine) = 1 & MessageSubject = "") then
do
MessageSubject = SUBSTR(WholeLine, 10)
end
/*Date: 12 Sep 1995 00:37:37 -0400 */
/*Date: Sun, 10 Sep 95 09:56:30 -0500 */
if (POS("Date: ",WholeLine) = 1 & MessageDate = "") then
do
if DATATYPE(WORD(WholeLine,2),N) then
do
Day = WORD(WholeLine,2)
Month = WORD(WholeLine,3)
Year = WORD(WholeLine,4)
TimeOfMessy = WORD(WholeLine,5)
end
else
do
Day = WORD(WholeLine,3)
Month = WORD(WholeLine,4)
Year = WORD(WholeLine,5)
TimeOfMessy = WORD(WholeLine,6)
end
if LENGTH(Day) = 1 then Day = "0"||Day
if Month = "Jan" then Month = 01
else if Month = "Feb" then Month = 02
else if Month = "Mar" then Month = 03
else if Month = "Apr" then Month = 04
else if Month = "May" then Month = 05
else if Month = "Jun" then Month = 06
else if Month = "Jul" then Month = 07
else if Month = "Aug" then Month = 08
else if Month = "Sep" then Month = 09
else if Month = "Oct" then Month = 10
else if Month = "Nov" then Month = 11
else Month = "Dec" then Month = 12
if LENGTH(Year) = 2 then Year = "19"||Year
ourdate = (((date('i',year||month||day,'s') + 2922) * 86400) + 21600)
hour = SUBSTR(TimeOfMessy, 1, 2)
hour = STRIP(hour, L, "0")
if hour = "" then hour = 0
minute = SUBSTR(TimeOfMessy, 4, 2)
minute = STRIP(minute, L, "0")
if minute = "" then minute = 0
seconds = SUBSTR(TimeOfMessy, 7, 2)
seconds = STRIP(seconds, L, "0")
if seconds = "" then seconds = 0
TimeOfMessy = (hour * 60 * 60) + (minute * 60) + seconds
MessageDate = ourdate + TimeOfMessy
/*say WholeLine*/
end
if (POS("From: ",WholeLine) = 1 & MessageFrom = "") then
do
MessageFromEmail = SUBSTR(WholeLine, 7)
if ((POS("(",WholeLine) = 0) & (POS("<",WholeLine) = 0)) then
do
MessageFrom = "Anonymous"
end
/*From: Nick Plante <nplante@delphi.com>*/
else if ((POS("(",WholeLine) = 0) & (POS(")",WholeLine) = 0)) then
do
MessageFrom = SUBSTR(WholeLine, 7, INDEX(WholeLine,"<") - 8)
end
/*From: bilboyce@iconz.co.nz (Bill Boyce)*/
else
do
a = INDEX(WholeLine,"(")
b = INDEX(WholeLine,")")
MessageFrom = SUBSTR(WholeLine, a + 1, (b - a) - 1)
end
end
/*Reply-To: dally28@aol.com (Dally28)*/
if (POS("Reply-To: ",WholeLine) = 1 & MessageToEmail = "") then
do
MessageToEmail = SUBSTR(WholeLine, 11)
end
if WholeLine = "" & FirstEmptyLine = "NO" then
do
FirstEmptyLine = "YES"
if MessageToEmail = "" then MessageToEmail = MessageFromEmail
say "From : ==>"||MessageFrom||"<=="
say "FromEmail: ==>"||MessageFromEmail||"<=="
say "ToEmail : ==>"||MessageToEmail||"<== **********************"
say "Date : ==>"||MessageDate||"<=="
say "Subject : ==>"||MessageSubject||"<=="
end
/* if this then write message */
if FirstEmptyLine = "YES" then writeln(MyTmpMsg,WholeLine)
end
CLOSE(MyFile)
Close(MyTmpMsg)
call AddMessageFullFunction
ADDRESS COMMAND "delete ram:tmp.msg"
/*
say "#### Message STARTS HERE ####"
ADDRESS COMMAND "type ram:tmp.msg"
say "#### Message STOPS HERE ####"
*/
end
else say "message # ==> "||i||" not found."
i = i + 1
end
say "Finished."
say ""
SAY 'Elapsed time='TIME('E')' seconds.'
Exit
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
/*******************************************************************************/
k = 0
j = 0
ok = "NO"
firstmsg = "YES"
if EXISTS("ram:temp.msg") then ADDRESS COMMAND "delete ram:temp.msg"
/* say UUNewsFalco */
call open MailHeaderFile,(UUNewsFalco),'R'
do while ~EOF(MailHeaderFile)
Message = readln(MailHeaderFile)
n = POS("From !",Message)
if n = 1 then do
if EXISTS("ram:temp.msg") then do
CLOSE(TempMsgBody)
end
if firstmsg = "NO" then call DoTheMessage
m = POS("From !owner-amiga",Message)
if m = 1 then ok = "YES"
else ok = "NO"
k = k + 1 /* how many messages found */
j = 1
say "########################### NEW MESSAGE ###########################"
firstmsg = "NO"
call open TempMsgBody,("ram:temp.msg"),'W'
end
n = POS("From: ",Message)
if n = 1 then do
MessageIsFrom = SUBSTR(Message, 7, (POS("<",Message,8) - 1) - 7)
say "From : ==>"||MessageIsFrom||"<=="
end
n = POS("Subject: ",Message)
if n = 1 then do
MessageSubjectIs = SUBSTR(Message, 10)
say "Subject : ==>"||MessageSubjectIs||"<=="
end
n = POS("Date: ",Message)
if n = 1 then do
Day = WORD(Message,3)
if LENGTH(Day) = 1 then Day = "0"||day
Month = WORD(Message,4)
if Month = "Jan" then Month = 01
if Month = "Feb" then Month = 02
if Month = "Mar" then Month = 03
if Month = "Apr" then Month = 04
if Month = "May" then Month = 05
if Month = "Jun" then Month = 06
if Month = "Jul" then Month = 07
if Month = "Aug" then Month = 08
if Month = "Sep" then Month = 09
if Month = "Oct" then Month = 10
if Month = "Nov" then Month = 11
if Month = "Dec" then Month = 12
Year = WORD(Message,5)
ourdate = (((date('i',year||month||day,'s') + 2922) * 86400) + 21600)
TimeOfMessy = WORD(Message,6)
hour = SUBSTR(TimeOfMessy, 1, 2)
hour = STRIP(hour, L, "0")
if hour = "" then hour = 0
minute = SUBSTR(TimeOfMessy, 4, 2)
minute = STRIP(minute, L, "0")
if minute = "" then minute = 0
seconds = SUBSTR(TimeOfMessy, 7, 2)
seconds = STRIP(seconds, L, "0")
if seconds = "" then seconds = 0
TimeOfMessy = (hour * 60 * 60) + (minute * 60) + seconds
MessageDateIs = ourdate + TimeOfMessy
end
n = POS(" ",Message)
if (n = 0) & (j = 1) then j = 0
/*******=======>>>>>>>>>>>>>>> if j = 0 then say Message */
if j = 0 & ok = "YES" then do
/* say Message*/
writeln(TempMsgBody,Message)
/*####################################################################
######################################################################
######################################################################
####################################################################*/
end
end
call DoTheMessage
say k||" <=== messages found"
call close(MailHeaderFile)
SAY 'Elapsed time='TIME('E')' seconds.'
Exit
DoTheMessage:
if EXISTS("ram:temp.msg") then do
CLOSE(TempMsgBody)
end
if ok = "YES" then do
/*
say "FromWhom = "||SUBSTR(MessageIsFrom,1,30)
say "MessySubject = "||SUBSTR(MessageSubjectIs,1,30)
say "DateMessySend = "||d2c(MessageDateIs)
*/
call AddMessageFullFunction
end
/* ADDRESS COMMAND "Type ram:temp.msg"*/
/*if EXISTS("ram:temp.msg") then if ok = "YES" then call AddMessageFullFunction*/
/* ADDRESS COMMAND "Type ram:temp.msg" */
ADDRESS COMMAND "delete ram:temp.msg"
return
AddMessageFullFunction:
/*
MessageFrom = ""
MessageSubject = ""
MessageDate = ""
MessageToEmail = "" /* Put this to comment of a message and then use to reply to it. */
FirstEmptyLine = "NO"
MessageFromEmail = ""
*/
MessyType = "P"
ToWhom = 'All'
FromWhom = SUBSTR(MessageFrom,1,30)
MessySubject = SUBSTR(MessageSubject,1,30)
/*say MessageDateIs*/
DateMessySend = d2c(MessageDate)
if ~exists(dir||'MsgBase/HeaderFile') then
do
call open fes, (dir||'MsgBase/HeaderFile'), 'W'
close(fes)
end
st = STATEF(dir||'MsgBase/HeaderFile')
parse var st type size blk bits day min tick com
num=size/110+1
numero=d2c(num)
call numm
cozza = ToWhom
clen=31
call add0
unome=cozza
cozza=FromWhom
call add0
chi=cozza
clen=32
cozza=MessySubject
call add0
motivo=cozza
ora = DateMessySend
txt=MessyType||'0'x||numero||unome||chi||motivo||ora||'0'x||'0'x||'0'x||'0'x||'0'x||'0'x
numero=d2c(num+1)
call numm
txt1='00000001'x||numero||'00000001000000000000'x
call open fes, (dir||'MsgBase/HeaderFile'), 'A'
writech(fes,txt)
close(fes)
call open fes, (dir||'MsgBase/MailStats'), 'W'
writech(fes,txt1)
close(fes)
/*
call open fes, (dir||'MsgBase/'||num), 'W'
writeln(fes,'this is a test of the message adder')
close(fes)
*/
cmd2exe = 'copy ram:tmp.msg '||dir||'MsgBase/'||num
ADDRESS COMMAND cmd2exe
/********** MAKE COMMENTS ***********/
/* Doesnt work since BBS thinks we are attaching a file to it. */
/*
MessageToEmail = '" '||MessageToEmail||'"'
cmd2exe = 'Filenote '||dir||'MsgBase/'||num||' '||MessageToEmail
ADDRESS COMMAND cmd2exe
*/
if ~exists(dir||'MsgBase/MailLock') then
do
call open fes, (dir||'MsgBase/MailLock'), 'W'
writech(fes,'DO NOT DELETE!'||'a'x)
close(fes)
end
say "Message Number "||num||"...done!"
tr
return
exit:
tr
exit
add0:
len=length(cozza)
do while len~=clen
cozza=cozza||'0'x
len=length(cozza)
end
return
numm:
len=length(numero)
do while len~=4
numero='0'x||numero
len=length(numero)
end